// 实现简单ajax请求代理
var delay = function (t) {
    return new Promise((resolve,reject) => {
        return setTimeout(() => {
            resolve()
        }, t);
    })
}

var axios = async function () {
    await delay(2000)
    const a = require("./a.json")
    return new Promise((resolve,reject) => {
        resolve(a)
    })
}

var getData = function () {
    axios().then(resp => {
        console.log(resp);
        return resp
    })
}

// getData()

var getDataProxy = (function () {
    var cache = {
        a: null
    }

    return function () {
        if(cache['a']){
            return cache['a']
        }
        return cache['a'] = getData()
    }
})()

getDataProxy()
getDataProxy()